package huoye.shops.huoye.operation.activity;

import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.codeideology.android.lang.entity.Paging;
import com.codeideology.android.widget.recycler.RecyclerViewAdapter;

import butterknife.OnClick;
import huoye.shops.R;
import huoye.shops.base.BaseActivity;
import huoye.shops.base.PullToRefreshActivity;
import huoye.shops.huoye.operation.adapter.VipGuestsAdapter;
import huoye.shops.huoye.operation.model.VipGustsData;
import huoye.shops.huoye.operation.presenter.VipGuestsPresenter;
import huoye.shops.huoye.operation.view.IVipGuestsRefreshView;
import huoye.shops.huoye.user.model.User;

public class VipGuestsActivity extends PullToRefreshActivity<VipGustsData> implements IVipGuestsRefreshView {

    private VipGuestsPresenter mVipGuestsPresenter;

    @OnClick(R.id.add_vip_guests_btn)
    void onAddGuests(){
        startActivity(NewAddGuestsActivity.class);
    }


    @Override
    protected int getContentViewId() {
        return R.layout.activity_vip_guests;
    }

    @Override
    public RecyclerViewAdapter createAdapter() {
        VipGuestsAdapter adapter = new VipGuestsAdapter(this);
        adapter.setOnVipGuestsListener(new VipGuestsAdapter.OnVipGuestsListener() {
            @Override
            public void onEditClick(VipGustsData vipGustsData) {
                vipGustsData.setEdit(true);
                startActivity(GuestsSetActivity.class,vipGustsData);
            }

            @Override
            public void onDeleteClick(VipGustsData vipGustsData) {
                mVipGuestsPresenter.delPrivilegedGuest(vipGustsData.getShopSpeGuestId());
            }
        });
        return adapter;
    }

    @Override
    protected void initView(@Nullable Bundle bundle) {
        super.initView(bundle);
        setTitle("特约嘉宾");
        mVipGuestsPresenter = new VipGuestsPresenter();
        mVipGuestsPresenter.addTaskListener(this);
        mVipGuestsPresenter.onStart();
        query();

    }


    @Override
    public void query(Paging paging) {
        super.query(paging);
        //获取特权用户列表
        mVipGuestsPresenter.postPrivilegedGuestList(paging);
    }


    @Override
    public void onItemClick(VipGustsData vipGustsData, int i, View view) {

    }

    @Override
    public void refreshPage() {
        makeToast("该用户权限删除成功");
        query();
    }
}
